import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'
// import { useCounterStore } from '@/stores/counter'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    // {
    //   path: '/',
    //   name: 'home',
    //   component: HomeView,
    // },
    // {
    //   path: '/about',
    //   name: 'about',
    //   // route level code-splitting
    //   // this generates a separate chunk (About.[hash].js) for this route
    //   // which is lazy-loaded when the route is visited.
    //   component: () => import('../views/AboutView.vue'),
    // },
    {
      path: '/',
      name: 'Login',
      component: () => import('../views/Login.vue'),
    },
    {
      path: '/Main',
      name: 'Main',
      component: () => import('../views/MainView.vue'),
      children: [
        {
          path: '/Menu',
          name: 'Menu',
          component: () => import('../views/MenuView.vue'),
          children: [
            {
              path: '/List',
              name: 'List',
              component: () => import('../views/List.vue'),
            },
            {
              path: '/RoleList',
              name: 'RoleList',
              component: () => import('../views/Role/RoleListView.vue'),
            },
            {
              path: '/PermisiList',
              name: 'PermisiList',
              component: () => import('../views/Permisi/PermisiList.vue'),
            },
          ],
        },
      ],
    },
  ],
})

//定义路由守卫
// router.beforeEach((to, from, text) => {
//   const counterStore = useCounterStore()
//   if (to.name == 'Login') {
//     text()
//   } else if (counterStore.is_login == true) {
//     text()
//   } else text({ name: 'Login' })
// })

export default router
